odoo.define('custom.select_x2many', function (require) {
    "use strict";
    var fields = require('web.relational_fields');
    var fieldRegistry = require('web.field_registry');
    var core = require('web.core');
    var Context = require('web.Context');
    var _t = core._t;
    var FieldMany2One = fields.FieldMany2One;
    var FieldOne2Many = fields.FieldOne2Many;
    var FieldMany2Many = fields.FieldMany2Many;
    var FieldMany2ManyTags = fields.FieldMany2ManyTags;
    var SelectFieldMany2ManyTag = FieldMany2ManyTags.extend({
        custom_events: _.extend({}, FieldMany2ManyTags.prototype.custom_events, {
            m2m_request: '_onM2MRequest',
        }),
        _onM2MRequest: function (ev) {
            this.many2one._searchCreatePopup('search', false, {}, undefined);
        },
        //
    });
    var SelectFieldMany2OneMany = FieldOne2Many.extend({
         _onAddRecord: function (ev)  {
                _.each(this.getParent().getChildren(), function (child) {
                    child.trigger_up('m2m_request');
                    return;
                });
                return;
        },

    });
fieldRegistry.add('select_many2many_tags',SelectFieldMany2ManyTag);
fieldRegistry.add('select_one2many',SelectFieldMany2OneMany)

});